#!/usr/bin/perl -w

use strict;
use DBI;
#use Time::localtime ;
#use Time::Local ;
use POSIX qw(strftime);
use Data::Dumper;

use CGI qw(:standard);

use MIME::Lite; 



my ($res_db,@res_db,$sth2,@res_db2,$resdays,$note,$cmnd,@cmnd);
my ($now,$now_month,$studentid,$step,$msg2,$msg3);
my ($dbh,$dbh1,$sth,$id,$val,$msg,$id2,$email2,$email);
my ($j,$i,$f,$s,$path,$treningid,@contactmembers,$countcontactmembers,$contactmembers);
my ($ATTFILE,$SUBJECT,$MAILTO,$TXTFILE,$add_request,$SUBJECT2,$daysofpause,$statusring,%commtime);

#$path="/home/bukvy/data/www/bukvy.ru/cgi-bin/";
$path="/home/trening/data/public_html/cgi-bin/";







#$dbh=DBI->connect("dbi:mysql:dbname=sms:host=localhost","ddumper","ddumper");
$dbh=DBI->connect("dbi:mysql:dbname=ss77ru:host=localhost","ss77ru","662720");
        if(!$dbh) {                print "Cannot connect: $DBI::errstr";
                   }


$sth=$dbh->do("set character_set_results='cp1251'");
$sth=$dbh->do("set character_set_client='cp1251'");
$sth=$dbh->do("set collation_connection='cp1251_general_ci'");

$i=0;
$j=0;

my ($id2,$vid);


	$sth=$dbh->prepare("SELECT id from trening"); 
	$sth->execute();
	while ($id = $sth->fetchrow_array) 
	{ # getting of the result
	   if ($id) {
		$vid=(rand(1)*1000000000);
		while ($id2=$dbh->selectrow_array("SELECT id from trening where $vid=vid")){
		$vid=(rand(1)*1000000000);}
		$dbh->do("UPDATE trening set vid=$vid where id=$id");
	    }                             	
	}


